﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace UltimateFracturing
{
	// Token: 0x02000442 RID: 1090
	public class MeshData
	{
		// Token: 0x06001E76 RID: 7798 RVA: 0x000C2627 File Offset: 0x000C0827
		private MeshData()
		{
			this.meshDataConnectivity = new MeshDataConnectivity();
			this.aMaterials = new Material[1];
			this.aMaterials[0] = null;
		}

		// Token: 0x06001E77 RID: 7799 RVA: 0x000C2650 File Offset: 0x000C0850
		public MeshData(Material[] aMaterials, List<int>[] alistIndices, List<VertexData> listVertexData, int nSplitCloseSubMesh, Vector3 v3Position, Quaternion qRotation, Vector3 v3Scale, Matrix4x4 mtxTransformVertices, bool bUseTransform, bool bBuildVertexHashData)
		{
			this.nSubMeshCount = alistIndices.Length;
			this.aaIndices = new int[this.nSubMeshCount][];
			for (int i = 0; i < this.nSubMeshCount; i++)
			{
				this.aaIndices[i] = alistIndices[i].ToArray();
			}
			this.nSplitCloseSubMesh = nSplitCloseSubMesh;
			this.aVertexData = listVertexData.ToArray();
			if (bUseTransform)
			{
				for (int j = 0; j < this.aVertexData.Length; j++)
				{
					this.aVertexData[j].v3Vertex = mtxTransformVertices.MultiplyPoint3x4(this.aVertexData[j].v3Vertex);
				}
			}
			MeshData.ComputeMinMax(this.aVertexData, ref this.v3Min, ref this.v3Max);
			this.v3Position = v3Position;
			this.qRotation = qRotation;
			this.v3Scale = v3Scale;
			this.meshDataConnectivity = new MeshDataConnectivity();
			if (bBuildVertexHashData)
			{
				this.BuildVertexHashData();
			}
			if (aMaterials != null)
			{
				this.aMaterials = new Material[aMaterials.Length];
				aMaterials.CopyTo(this.aMaterials, 0);
			}
			else
			{
				this.aMaterials = new Material[1];
				this.aMaterials[0] = null;
			}
		}

		// Token: 0x06001E78 RID: 7800 RVA: 0x000C277C File Offset: 0x000C097C
		public MeshData(Transform transform, Mesh mesh, Material[] aMaterials, Matrix4x4 mtxLocalToWorld, bool bTransformVerticesToWorld, int nSplitCloseSubMesh, bool bBuildVertexHashData) : this(transform.position, transform.rotation, transform.localScale, mesh, aMaterials, mtxLocalToWorld, bTransformVerticesToWorld, nSplitCloseSubMesh, bBuildVertexHashData)
		{
		}

		// Token: 0x06001E79 RID: 7801 RVA: 0x000C27AC File Offset: 0x000C09AC
		public MeshData(Vector3 v3Position, Quaternion qRotation, Vector3 v3Scale, Mesh mesh, Material[] aMaterials, Matrix4x4 mtxLocalToWorld, bool bTransformVerticesToWorld, int nSplitCloseSubMesh, bool bBuildVertexHashData)
		{
			this.nSubMeshCount = mesh.subMeshCount;
			this.aaIndices = new int[this.nSubMeshCount][];
			for (int i = 0; i < this.nSubMeshCount; i++)
			{
				this.aaIndices[i] = mesh.GetTriangles(i);
			}
			this.nSplitCloseSubMesh = nSplitCloseSubMesh;
			this.aVertexData = VertexData.BuildVertexDataArray(mesh, mtxLocalToWorld, bTransformVerticesToWorld);
			MeshData.ComputeMinMax(this.aVertexData, ref this.v3Min, ref this.v3Max);
			this.v3Position = v3Position;
			this.qRotation = qRotation;
			this.v3Scale = v3Scale;
			if (bTransformVerticesToWorld)
			{
				v3Scale = Vector3.one;
			}
			this.meshDataConnectivity = new MeshDataConnectivity();
			if (bBuildVertexHashData)
			{
				this.BuildVertexHashData();
			}
			if (aMaterials != null)
			{
				this.aMaterials = new Material[aMaterials.Length];
				aMaterials.CopyTo(this.aMaterials, 0);
			}
			else
			{
				this.aMaterials = new Material[1];
				this.aMaterials[0] = null;
			}
		}

		// Token: 0x06001E7A RID: 7802 RVA: 0x000C28B0 File Offset: 0x000C0AB0
		public static MeshData CreateBoxMeshData(Vector3 v3Pos, Quaternion qRot, Vector3 v3Scale, Vector3 v3Min, Vector3 v3Max)
		{
			MeshData meshData = new MeshData();
			meshData.nSubMeshCount = 1;
			meshData.aaIndices = new int[1][];
			meshData.aaIndices[0] = new int[]
			{
				1,
				0,
				3,
				1,
				3,
				2,
				4,
				5,
				7,
				5,
				6,
				7,
				0,
				4,
				3,
				4,
				7,
				3,
				7,
				2,
				3,
				7,
				6,
				2,
				5,
				0,
				1,
				5,
				4,
				0,
				6,
				1,
				2,
				6,
				5,
				1
			};
			meshData.nSplitCloseSubMesh = 0;
			Vector3[] array = new Vector3[]
			{
				new Vector3(v3Min.x, v3Min.y, v3Min.z),
				new Vector3(v3Min.x, v3Min.y, v3Max.z),
				new Vector3(v3Max.x, v3Min.y, v3Max.z),
				new Vector3(v3Max.x, v3Min.y, v3Min.z),
				new Vector3(v3Min.x, v3Max.y, v3Min.z),
				new Vector3(v3Min.x, v3Max.y, v3Max.z),
				new Vector3(v3Max.x, v3Max.y, v3Max.z),
				new Vector3(v3Max.x, v3Max.y, v3Min.z)
			};
			meshData.aVertexData = new VertexData[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				meshData.aVertexData[i] = new VertexData(i);
				meshData.aVertexData[i].v3Vertex = array[i];
			}
			meshData.v3Position = v3Pos;
			meshData.qRotation = qRot;
			meshData.v3Scale = v3Scale;
			meshData.v3Min = v3Min;
			meshData.v3Max = v3Max;
			meshData.nCurrentVertexHash = 8;
			return meshData;
		}

		// Token: 0x06001E7B RID: 7803 RVA: 0x000C2AA4 File Offset: 0x000C0CA4
		public MeshData GetDeepCopy()
		{
			MeshData meshData = new MeshData();
			meshData.nSubMeshCount = this.nSubMeshCount;
			meshData.aaIndices = new int[this.nSubMeshCount][];
			for (int i = 0; i < this.nSubMeshCount; i++)
			{
				meshData.aaIndices[i] = new int[this.aaIndices[i].Length];
				this.aaIndices[i].CopyTo(meshData.aaIndices[i], 0);
			}
			meshData.nSplitCloseSubMesh = this.nSplitCloseSubMesh;
			meshData.aVertexData = new VertexData[this.aVertexData.Length];
			this.aVertexData.CopyTo(meshData.aVertexData, 0);
			meshData.v3Position = this.v3Position;
			meshData.qRotation = this.qRotation;
			meshData.v3Scale = this.v3Scale;
			meshData.v3Min = this.v3Min;
			meshData.v3Max = this.v3Max;
			meshData.nCurrentVertexHash = this.nCurrentVertexHash;
			meshData.meshDataConnectivity = this.meshDataConnectivity.GetDeepCopy();
			meshData.aMaterials = new Material[this.aMaterials.Length];
			this.aMaterials.CopyTo(meshData.aMaterials, 0);
			return meshData;
		}

		// Token: 0x06001E7C RID: 7804 RVA: 0x000C2BC8 File Offset: 0x000C0DC8
		public bool FillMeshFilter(MeshFilter meshFilter, bool bTransformVerticesToLocal)
		{
			meshFilter.transform.position = this.v3Position;
			meshFilter.transform.rotation = this.qRotation;
			meshFilter.transform.localScale = this.v3Scale;
			meshFilter.sharedMesh = new Mesh();
			Mesh sharedMesh = meshFilter.sharedMesh;
			VertexData.SetMeshDataFromVertexDataArray(meshFilter, this, bTransformVerticesToLocal);
			sharedMesh.subMeshCount = this.nSubMeshCount;
			for (int i = 0; i < this.nSubMeshCount; i++)
			{
				sharedMesh.SetTriangles(this.aaIndices[i], i);
			}
			sharedMesh.RecalculateBounds();
			return true;
		}

		// Token: 0x06001E7D RID: 7805 RVA: 0x000C2C5C File Offset: 0x000C0E5C
		public static void ComputeMinMax(IEnumerable<VertexData> VertexData, ref Vector3 v3Min, ref Vector3 v3Max)
		{
			v3Min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
			v3Max = new Vector3(float.MinValue, float.MinValue, float.MinValue);
			foreach (VertexData vertexData in VertexData)
			{
				if (vertexData.v3Vertex.x < v3Min.x)
				{
					v3Min.x = vertexData.v3Vertex.x;
				}
				if (vertexData.v3Vertex.y < v3Min.y)
				{
					v3Min.y = vertexData.v3Vertex.y;
				}
				if (vertexData.v3Vertex.z < v3Min.z)
				{
					v3Min.z = vertexData.v3Vertex.z;
				}
				if (vertexData.v3Vertex.x > v3Max.x)
				{
					v3Max.x = vertexData.v3Vertex.x;
				}
				if (vertexData.v3Vertex.y > v3Max.y)
				{
					v3Max.y = vertexData.v3Vertex.y;
				}
				if (vertexData.v3Vertex.z > v3Max.z)
				{
					v3Max.z = vertexData.v3Vertex.z;
				}
			}
		}

		// Token: 0x06001E7E RID: 7806 RVA: 0x000C2DCC File Offset: 0x000C0FCC
		private void BuildVertexHashData()
		{
			List<Dictionary<int, Vector3>> list = new List<Dictionary<int, Vector3>>();
			List<float> list2 = new List<float>();
			int num = this.aVertexData.Length / Parameters.VERTICESSPACESUBDIVISION + 1;
			for (int i = 0; i < num; i++)
			{
				float item = this.v3Min.y + (float)(i + 1) / (float)num * (this.v3Max.y - this.v3Min.y);
				list.Add(new Dictionary<int, Vector3>());
				list2.Add(item);
			}
			int[] array = new int[3];
			this.nCurrentVertexHash = 0;
			int num2 = 0;
			for (int j = 0; j < this.aVertexData.Length; j++)
			{
				Vector3 v3Vertex = this.aVertexData[j].v3Vertex;
				int num3 = Mathf.FloorToInt((v3Vertex.y - this.v3Min.y) / (this.v3Max.y - this.v3Min.y) * (float)list2.Count);
				if (num3 < 0)
				{
					num3 = 0;
				}
				if (num3 >= list2.Count)
				{
					num3 = list2.Count - 1;
				}
				array[0] = num3;
				array[1] = -1;
				array[2] = -1;
				int num4 = 1;
				if (Mathf.Abs(list2[num3] - v3Vertex.y) < Parameters.EPSILONDISTANCEPLANE && num3 < list2.Count - 1)
				{
					array[num4++] = num3 + 1;
				}
				if (num3 > 0 && Mathf.Abs(list2[num3 - 1] - v3Vertex.y) < Parameters.EPSILONDISTANCEPLANE)
				{
					array[num4++] = num3 - 1;
				}
				int num5 = -1;
				foreach (int num6 in array)
				{
					if (num6 != -1)
					{
						foreach (KeyValuePair<int, Vector3> keyValuePair in list[num6])
						{
							if (Vector3.Distance(keyValuePair.Value, v3Vertex) < Parameters.EPSILONDISTANCEVERTEX)
							{
								num5 = keyValuePair.Key;
								break;
							}
						}
					}
				}
				if (num5 == -1)
				{
					int num7 = this.nCurrentVertexHash++;
					list[num3].Add(num7, v3Vertex);
					this.aVertexData[j].nVertexHash = num7;
					num2++;
				}
				else
				{
					this.aVertexData[j].nVertexHash = num5;
				}
			}
		}

		// Token: 0x06001E7F RID: 7807 RVA: 0x000C3064 File Offset: 0x000C1264
		public bool GetSharedFacesArea(FracturedObject fracturedComponent, MeshData meshData2, out float fSharedArea)
		{
			fSharedArea = 0f;
			bool result = false;
			foreach (int key in this.meshDataConnectivity.dicHash2FaceList.Keys)
			{
				if (meshData2.meshDataConnectivity.dicHash2FaceList.ContainsKey(key))
				{
					foreach (MeshDataConnectivity.Face face in this.meshDataConnectivity.dicHash2FaceList[key])
					{
						Vector3 v3Vertex = this.aVertexData[this.aaIndices[face.nSubMesh][face.nFaceIndex * 3]].v3Vertex;
						Vector3 v3Vertex2 = this.aVertexData[this.aaIndices[face.nSubMesh][face.nFaceIndex * 3 + 1]].v3Vertex;
						Vector3 v3Vertex3 = this.aVertexData[this.aaIndices[face.nSubMesh][face.nFaceIndex * 3 + 2]].v3Vertex;
						float magnitude = Vector3.Cross(v3Vertex3 - v3Vertex, v3Vertex2 - v3Vertex).magnitude;
						foreach (MeshDataConnectivity.Face face2 in meshData2.meshDataConnectivity.dicHash2FaceList[key])
						{
							Vector3 v3Vertex4 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3]].v3Vertex;
							Vector3 v3Vertex5 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3 + 1]].v3Vertex;
							Vector3 v3Vertex6 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3 + 2]].v3Vertex;
							float magnitude2 = Vector3.Cross(v3Vertex6 - v3Vertex4, v3Vertex5 - v3Vertex4).magnitude;
							bool flag = false;
							if (MeshData.Face2InsideFace1(fracturedComponent, this, meshData2, face, face2))
							{
								flag = true;
							}
							else if (MeshData.Face2InsideFace1(fracturedComponent, meshData2, this, face2, face))
							{
								flag = true;
							}
							if (flag)
							{
								fSharedArea += Mathf.Min(magnitude, magnitude2);
								result = true;
							}
						}
					}
				}
			}
			return result;
		}

		// Token: 0x06001E80 RID: 7808 RVA: 0x000C3320 File Offset: 0x000C1520
		private static bool Face2InsideFace1(FracturedObject fracturedComponent, MeshData meshData1, MeshData meshData2, MeshDataConnectivity.Face face1, MeshDataConnectivity.Face face2)
		{
			if (fracturedComponent.FracturePattern == FracturedObject.EFracturePattern.BSP && !meshData1.meshDataConnectivity.dicFace2IsClipped.ContainsKey(face1) && !meshData2.meshDataConnectivity.dicFace2IsClipped.ContainsKey(face2))
			{
				return true;
			}
			Vector3 v3Vertex = meshData1.aVertexData[meshData1.aaIndices[face1.nSubMesh][face1.nFaceIndex * 3]].v3Vertex;
			Vector3 v3Vertex2 = meshData1.aVertexData[meshData1.aaIndices[face1.nSubMesh][face1.nFaceIndex * 3 + 1]].v3Vertex;
			Vector3 v3Vertex3 = meshData1.aVertexData[meshData1.aaIndices[face1.nSubMesh][face1.nFaceIndex * 3 + 2]].v3Vertex;
			Vector3 vector = -Vector3.Cross(v3Vertex2 - v3Vertex, v3Vertex3 - v3Vertex);
			float magnitude = vector.magnitude;
			if (magnitude < Parameters.EPSILONCROSSPRODUCT)
			{
				return false;
			}
			Quaternion q = Quaternion.LookRotation(vector.normalized, (v3Vertex2 - v3Vertex).normalized);
			Matrix4x4 inverse = Matrix4x4.TRS(v3Vertex, q, Vector3.one).inverse;
			Vector3 v3Vertex4 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3]].v3Vertex;
			Vector3 v3Vertex5 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3 + 1]].v3Vertex;
			Vector3 v3Vertex6 = meshData2.aVertexData[meshData2.aaIndices[face2.nSubMesh][face2.nFaceIndex * 3 + 2]].v3Vertex;
			Vector3 vector2 = (v3Vertex4 + v3Vertex5 + v3Vertex6) / 3f;
			vector2 = inverse.MultiplyPoint3x4(vector2);
			Vector3 a = inverse.MultiplyPoint3x4(v3Vertex);
			Vector3 b = inverse.MultiplyPoint3x4(v3Vertex2);
			Vector3 vector3 = inverse.MultiplyPoint3x4(v3Vertex3);
			Vector3 lhs = vector3 - b;
			Vector3 lhs2 = a - vector3;
			bool flag = false;
			if (vector2.x >= 0f && Vector3.Cross(lhs, vector2 - b).z <= 0f && Vector3.Cross(lhs2, vector2 - vector3).z <= 0f)
			{
				flag = true;
			}
			if (!flag)
			{
				Vector3 vector4 = inverse.MultiplyPoint3x4(v3Vertex4);
				Vector3 vector5 = inverse.MultiplyPoint3x4(v3Vertex5);
				Vector3 vector6 = inverse.MultiplyPoint3x4(v3Vertex6);
				if (!flag && Fracturer.IntersectEdges2D(vector4.x, vector4.y, vector5.x, vector5.y, a.x, a.y, b.x, b.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector4.x, vector4.y, vector5.x, vector5.y, b.x, b.y, vector3.x, vector3.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector4.x, vector4.y, vector5.x, vector5.y, vector3.x, vector3.y, a.x, a.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector5.x, vector5.y, vector6.x, vector6.y, a.x, a.y, b.x, b.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector5.x, vector5.y, vector6.x, vector6.y, b.x, b.y, vector3.x, vector3.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector5.x, vector5.y, vector6.x, vector6.y, vector3.x, vector3.y, a.x, a.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector6.x, vector6.y, vector4.x, vector4.y, a.x, a.y, b.x, b.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector6.x, vector6.y, vector4.x, vector4.y, b.x, b.y, vector3.x, vector3.y))
				{
					flag = true;
				}
				if (!flag && Fracturer.IntersectEdges2D(vector6.x, vector6.y, vector4.x, vector4.y, vector3.x, vector3.y, a.x, a.y))
				{
					flag = true;
				}
			}
			return flag;
		}

		// Token: 0x06001E81 RID: 7809 RVA: 0x000C3844 File Offset: 0x000C1A44
		public static List<MeshData> PostProcessConnectivity(MeshData meshDataSource, MeshFaceConnectivity connectivity, MeshDataConnectivity meshConnectivity, List<int>[] alistIndices, List<VertexData> listVertexData, int nSplitCloseSubMesh, int nCurrentVertexHash, bool bTransformToLocal)
		{
			List<MeshData> list = new List<MeshData>();
			List<int>[] array = new List<int>[alistIndices.Length];
			int[] array2 = new int[alistIndices.Length];
			int num = 0;
			List<int>[] array3 = new List<int>[alistIndices.Length];
			List<VertexData> list2 = new List<VertexData>();
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			for (int i = 0; i < alistIndices.Length; i++)
			{
				array[i] = new List<int>();
				for (int j = 0; j < alistIndices[i].Count / 3; j++)
				{
					array[i].Add(j);
				}
				array2[i] = num;
				num += alistIndices[i].Count / 3;
				array3[i] = new List<int>();
			}
			while (MeshData.StillHasFacesToProcess(array))
			{
				for (int k = 0; k < array.Length; k++)
				{
					if (array[k].Count > 0)
					{
						dictionary.Clear();
						list2.Clear();
						MeshDataConnectivity meshConnectivityOut = new MeshDataConnectivity();
						for (int l = 0; l < alistIndices.Length; l++)
						{
							array3[l].Clear();
						}
						MeshData.LookForClosedObjectRecursive(connectivity, meshConnectivity, k, array[k][0], alistIndices, listVertexData, array, array2, array3, list2, dictionary, meshConnectivityOut);
						Vector3 zero = Vector3.zero;
						Vector3 zero2 = Vector3.zero;
						MeshData.ComputeMinMax(list2, ref zero, ref zero2);
						Vector3 pos = (zero + zero2) * 0.5f;
						Matrix4x4 mtxTransformVertices = Matrix4x4.TRS(pos, meshDataSource.qRotation, meshDataSource.v3Scale);
						list.Add(new MeshData(meshDataSource.aMaterials, array3, list2, nSplitCloseSubMesh, pos, meshDataSource.qRotation, meshDataSource.v3Scale, mtxTransformVertices, bTransformToLocal, false)
						{
							meshDataConnectivity = meshConnectivityOut,
							nCurrentVertexHash = nCurrentVertexHash
						});
					}
				}
			}
			return list;
		}

		// Token: 0x06001E82 RID: 7810 RVA: 0x000C3A00 File Offset: 0x000C1C00
		private static bool StillHasFacesToProcess(List<int>[] alistFacesRemaining)
		{
			foreach (List<int> list in alistFacesRemaining)
			{
				if (list.Count > 0)
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06001E83 RID: 7811 RVA: 0x000C3A38 File Offset: 0x000C1C38
		private static void LookForClosedObjectRecursive(MeshFaceConnectivity connectivity, MeshDataConnectivity meshConnectivity, int nSubMeshStart, int nFaceSubMeshStart, List<int>[] alistIndicesIn, List<VertexData> listVertexDataIn, List<int>[] alistFacesRemainingInOut, int[] aLinearFaceIndexStart, List<int>[] alistIndicesOut, List<VertexData> listVertexDataOut, Dictionary<int, int> dicVertexRemap, MeshDataConnectivity meshConnectivityOut)
		{
			MeshFaceConnectivity.TriangleData triangleData = connectivity.listTriangles[aLinearFaceIndexStart[nSubMeshStart] + nFaceSubMeshStart];
			if (triangleData.bVisited)
			{
				return;
			}
			meshConnectivityOut.NotifyRemappedFace(meshConnectivity, nSubMeshStart, nFaceSubMeshStart, nSubMeshStart, alistIndicesOut[nSubMeshStart].Count / 3);
			for (int i = 0; i < 3; i++)
			{
				int num = alistIndicesIn[nSubMeshStart][nFaceSubMeshStart * 3 + i];
				if (dicVertexRemap.ContainsKey(num))
				{
					alistIndicesOut[nSubMeshStart].Add(dicVertexRemap[num]);
				}
				else
				{
					int count = listVertexDataOut.Count;
					alistIndicesOut[nSubMeshStart].Add(count);
					listVertexDataOut.Add(listVertexDataIn[num].Copy());
					dicVertexRemap.Add(num, count);
				}
			}
			alistFacesRemainingInOut[nSubMeshStart].Remove(nFaceSubMeshStart);
			triangleData.bVisited = true;
			for (int j = 0; j < 3; j++)
			{
				MeshFaceConnectivity.TriangleData triangleData2 = null;
				for (int k = 0; k < triangleData.alistNeighborSubMeshes[j].Count; k++)
				{
					if (triangleData.alistNeighborSubMeshes[j][k] != -1 && triangleData.alistNeighborTriangles[j][k] != -1)
					{
						triangleData2 = connectivity.listTriangles[aLinearFaceIndexStart[triangleData.alistNeighborSubMeshes[j][k]] + triangleData.alistNeighborTriangles[j][k]];
					}
					if (triangleData2 != null && !triangleData2.bVisited)
					{
						MeshData.LookForClosedObjectRecursive(connectivity, meshConnectivity, triangleData2.nSubMesh, triangleData2.nTriangle, alistIndicesIn, listVertexDataIn, alistFacesRemainingInOut, aLinearFaceIndexStart, alistIndicesOut, listVertexDataOut, dicVertexRemap, meshConnectivityOut);
					}
				}
			}
		}

		// Token: 0x04001EF4 RID: 7924
		public int nSubMeshCount;

		// Token: 0x04001EF5 RID: 7925
		public int[][] aaIndices;

		// Token: 0x04001EF6 RID: 7926
		public int nSplitCloseSubMesh;

		// Token: 0x04001EF7 RID: 7927
		public VertexData[] aVertexData;

		// Token: 0x04001EF8 RID: 7928
		public Vector3 v3Position;

		// Token: 0x04001EF9 RID: 7929
		public Quaternion qRotation;

		// Token: 0x04001EFA RID: 7930
		public Vector3 v3Scale;

		// Token: 0x04001EFB RID: 7931
		public Vector3 v3Min;

		// Token: 0x04001EFC RID: 7932
		public Vector3 v3Max;

		// Token: 0x04001EFD RID: 7933
		public int nCurrentVertexHash;

		// Token: 0x04001EFE RID: 7934
		public Material[] aMaterials;

		// Token: 0x04001EFF RID: 7935
		public MeshDataConnectivity meshDataConnectivity;

		// Token: 0x02000443 RID: 1091
		public class IncreasingSizeComparer : IComparer<MeshData>
		{
			// Token: 0x06001E84 RID: 7812 RVA: 0x000C3BCF File Offset: 0x000C1DCF
			public IncreasingSizeComparer(int nSplitAxis)
			{
				this.nSplitAxis = nSplitAxis;
			}

			// Token: 0x06001E85 RID: 7813 RVA: 0x000C3BE0 File Offset: 0x000C1DE0
			public int Compare(MeshData a, MeshData b)
			{
				Vector3 v3Min = a.v3Min;
				Vector3 v3Max = a.v3Max;
				Vector3 v3Min2 = b.v3Min;
				Vector3 v3Max2 = b.v3Max;
				if (this.nSplitAxis == 0)
				{
					return (v3Max.x - v3Min.x - (v3Max2.x - v3Min2.x) >= 0f) ? 1 : -1;
				}
				if (this.nSplitAxis == 1)
				{
					return (v3Max.y - v3Min.y - (v3Max2.y - v3Min2.y) >= 0f) ? 1 : -1;
				}
				if (this.nSplitAxis == 2)
				{
					return (v3Max.z - v3Min.z - (v3Max2.z - v3Min2.z) >= 0f) ? 1 : -1;
				}
				return (Mathf.Max(new float[]
				{
					v3Max.x - v3Min.x,
					v3Max.y - v3Min.y,
					v3Max.z - v3Min.z
				}) - Mathf.Max(new float[]
				{
					v3Max2.x - v3Min2.x,
					v3Max2.y - v3Min2.y,
					v3Max2.z - v3Min2.z
				}) >= 0f) ? 1 : -1;
			}

			// Token: 0x04001F00 RID: 7936
			private int nSplitAxis;
		}

		// Token: 0x02000444 RID: 1092
		public class DecreasingSizeComparer : IComparer<MeshData>
		{
			// Token: 0x06001E86 RID: 7814 RVA: 0x000C3D53 File Offset: 0x000C1F53
			public DecreasingSizeComparer(int nSplitAxis)
			{
				this.nSplitAxis = nSplitAxis;
			}

			// Token: 0x06001E87 RID: 7815 RVA: 0x000C3D64 File Offset: 0x000C1F64
			public int Compare(MeshData a, MeshData b)
			{
				Vector3 v3Min = a.v3Min;
				Vector3 v3Max = a.v3Max;
				Vector3 v3Min2 = b.v3Min;
				Vector3 v3Max2 = b.v3Max;
				if (this.nSplitAxis == 0)
				{
					return (v3Max.x - v3Min.x - (v3Max2.x - v3Min2.x) >= 0f) ? -1 : 1;
				}
				if (this.nSplitAxis == 1)
				{
					return (v3Max.y - v3Min.y - (v3Max2.y - v3Min2.y) >= 0f) ? -1 : 1;
				}
				if (this.nSplitAxis == 2)
				{
					return (v3Max.z - v3Min.z - (v3Max2.z - v3Min2.z) >= 0f) ? -1 : 1;
				}
				return (Mathf.Max(new float[]
				{
					v3Max.x - v3Min.x,
					v3Max.y - v3Min.y,
					v3Max.z - v3Min.z
				}) - Mathf.Max(new float[]
				{
					v3Max2.x - v3Min2.x,
					v3Max2.y - v3Min2.y,
					v3Max2.z - v3Min2.z
				}) >= 0f) ? -1 : 1;
			}

			// Token: 0x04001F01 RID: 7937
			private int nSplitAxis;
		}
	}
}
